// https://www.luogu.com.cn/problem/B2048

# include <stdio.h>


int main() {
    int x;
    char ch;
    scanf("%d %c", &x, &ch);
    int y = 8;
    x -= 1000;
    if (x > 0) {
        int t = x / 500;
        x %= 500;
        y += 4 * t;
        if (x != 0) {
            y += 4;
        }
    }
    if (ch == 'y') {
        printf("%d", y+5);
    } else {
        printf("%d", y);
    }
    return 0;
}
